﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLKDS.DAL;
using QLKDS.DTO;
using DevExpress.XtraBars;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraEditors.Controls;

namespace QLKDS.Forms
{
    public partial class frmBookInventory : Form
    {
        #region Properties
        private BookStoreManager bookStoreManager;
        private StoreManager storeManager = new StoreManager();
        private BarManager barManagerContext;
        private PopupMenu menuContext;

        #endregion


        #region Methods

        public frmBookInventory()
        {
            InitializeComponent();

            this.bookStoreManager = new BookStoreManager();
            this.grvBookstore.GroupPanelText = "Kéo một cột vào đây để nhóm dữ liệu";

            this.barManagerContext = new BarManager();
            this.menuContext = new PopupMenu();

            this.menuContext.ItemLinks.Add(new BarButtonItem(this.barManagerContext, "&Thêm mới"));
            this.menuContext.ItemLinks.Add(new BarButtonItem(this.barManagerContext, "&Sửa"));
            this.menuContext.ItemLinks.Add(new BarButtonItem(this.barManagerContext, "&Xóa"));
        }



        private void frmBookInventory_Load(object sender, EventArgs e)
        {
            // Population data on bookStore gridview
            this.PopulateBookInventoryGridView();

            this.lueStore.Properties.DataSource = this.storeManager.ListStore();
            this.lueStore.Properties.ValueMember = "Id";
            this.lueStore.Properties.DisplayMember = "Name";
        }

        private void frmBookInventory_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmMain.MainWindowManager.WindowNames.Remove(this.Name);
            frmMain.MainWindowManager.Windows.Remove(this);
        }

        public void PopulateBookInventoryGridView()
        {
            this.Cursor = Cursors.WaitCursor;

            this.gridBookstore.DataSource = this.bookStoreManager.ListBookStoreByStoreId(this.lueStore.Text.Trim());

            this.Cursor = Cursors.Default;
        }

        #endregion

        private void lueStore_EditValueChanged(object sender, EventArgs e)
        {
            this.PopulateBookInventoryGridView();
        }

      



     
    }
}
